package com.ts.code.creator.creator.impl;

import com.ts.code.creator.enums.CreateFileEnum;
import com.ts.code.creator.express.ExpressContext;
import com.ts.code.creator.express.ExpressUtil;
import com.ts.code.creator.util.CreateCodeContext;
import com.ts.code.creator.util.StringUtil;

/**
 * 聚合层 controller
 */
public class ServiceServiceImplCreator extends AbstractCodeCreator {

    public ServiceServiceImplCreator(CreateCodeContext context) {
        super(context);
    }

    @Override
    protected CreateFileEnum createFileEnum() {
        return CreateFileEnum.SERVICE_SERVICE_IMPL;
    }

    @Override
    public void doCreate() {
        // 服务层 serviceImpl
        addMethod(classFileSearch.serviceServiceImpl(), serviceServiceImpl(context));
    }

    private String serviceServiceImpl(CreateCodeContext context) {
        // @Override
        //    public WelfareQueryStatusRespDTO queryStatus(IdsReqDTO reqDTO) {
        //        return null;
        //    }

        String text = "@Override\n" +
                "public ${respDTO} ${methodName}(${serviceParamStr}) {\n" +
                "\n" +
                "    return null;\n" +
                "}";

        String reqDTO = reqDTO();
        ExpressContext expressContext = new ExpressContext();
        expressContext.put(context);
        expressContext.put("respDTO", respDTO());
        expressContext.put("returnType", adminVO());
        expressContext.put("serviceParamStr", reqDTO);
        expressContext.put("entityNameLower", StringUtil.firstLower(context.getEntityName()));
        return ExpressUtil.eval(text, expressContext);
    }

}
